import { ChooseQo } from '@/services/quest';
import { OptionsResult } from '@/store/answer/types';
// import { OptionsResult } from '@/store/answer/types';
import { Choose } from '../../types';

export default class ChosesAdapter {
  parse(value: Choose): ChooseQo {
    const vo: ChooseQo = {};

    vo.displayOrder = value.displayOrder;
    vo.content = value.content;

    return vo;
  }

  compose(value: OptionsResult, sum?: number): Choose {
    const vo: Choose = {
      content: value.content,
      detailsId: value.detailsId,
      displayOrder: value.displayOrder,
      queId: value.queId,
      answerPercent: value.answerPercent,
    };

    if (sum) {
      vo.proportion = value.answerPercent / sum;
    }
    return vo;
  }
}
